package com.example.cdctestsystem.managecontroller;

import com.example.cdctestsystem.pojo.Admin;
import com.example.cdctestsystem.service.AdminService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/manage")
public class AdminPermissionsController {
    @Resource
    private AdminService adminService;


    //取出所有管理员
    @RequestMapping("admin-list")
//    @ModelAttribute("adminList")
    public ModelAndView adminlist()
    {
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("adminList",adminService.getadmin());
        modelAndView.setViewName("/manage/admin-list");
        return modelAndView;
    }

    @RequestMapping("admin-add")
    public String adminadd()
    {
        return "/manage/admin-add";
    }


    @RequestMapping("tianjia")
    public String tianjia(Admin admin, HttpServletRequest request) {

        if (admin !=null)
        {

            adminService.adminadd(admin);
            return "/manage/admin-add";
        }
        else
        {
            return "/manage/admin-add";
        }


    }


}
